<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateProjectRelationTemplateTodoTable extends AbstractMigration
{
    public function up()
    {
        $this->table('project_relation_template_todo', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '项目关联模板待办表'])
            ->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('template_todo_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '模板待办id'])
            ->addColumn('project_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '项目id'])
            ->addColumn('step_category_config', 'json', ['null' => true, 'comment' => '关联环节'])
            ->addColumn('start_man', 'json', ['null' => true, 'comment' => '发起人'])
            ->addColumn('participant_man', 'json', ['null' => true, 'comment' => '执行人(参与人)'])
            ->addColumn('job_option', 'json', ['null' => true, 'comment' => '工作事项'])
            ->addColumn('after_option', 'json', ['null' => true, 'comment' => '后续事项'])
            ->addColumn('is_open', 'enum', ['values' => 'yes,no', 'default' => 'no', 'comment' => ' 模板是否启用'])
            ->addColumn('created', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '创建时间',])
            ->addColumn('updated', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '更新时间',])
            ->addColumn('created_by', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建者'])
            ->addColumn('updated_by', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '更新人',])
            ->save();
    }

    public function down()
    {
        $this->table('project_relation_template_todo')->drop()->save();
    }
}
